<template>
	<view class="page">
		<view class="cell-item">
			<view class="left-box">
				<view class="cell-title">
					收货地址
				</view>
			</view>
			<view class="right-box">
				<view class="value">
					{{addressinfo.city}}{{addressinfo.address}}
				</view>
				<view class="select-button" @click="AddressChange">
					选择
				</view>
			</view>
		</view>
		<view class="cell-item">
			<view class="left-box">
				<view class="cell-title">
					联系人
				</view>
			</view>
			<view class="right-box">
				<view class="value">
					{{addressinfo.name}}
				</view>
			</view>
		</view>
		<view class="cell-item">
			<view class="left-box">
				<view class="cell-title">
					联系方式
				</view>
			</view>
			<view class="right-box">
				<view class="value">
					{{addressinfo.phone}}
				</view>
			</view>
		</view>
		<view class="button" @click="saveChange">
			保存
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				addressinfo:{},
			}
		},
		onLoad() {
			this.addressinfo = getApp().globalData.address;
		},
		onShow() {
			let data = getApp().globalData.selected;
			if(data){
			this.addressinfo = data;
			}
		},
		onUnload() {
			 getApp().globalData.selected = null;
		},
		methods: {
			/**
			 * 选择地址改变触发事件
			 */
			AddressChange:function(){
				uni.navigateTo({
					url: '/subcontractList/order/address/index/index'
				});
			},
			/**
			 * 保存地址触发事件
			 */
			saveChange:function(){
				getApp().globalData.address = this.addressinfo;
				uni.navigateBack();
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		background-color: #f6f6f6;
		width: 100%;
		min-height: 100vh;

		.cell-item {
			box-sizing: border-box;
			padding: 0 20rpx;
			line-height: 80rpx;
			font-size: 28rpx;
			background-color: white;
			border-bottom: 1px solid #f0f0f0;
			display: flex;
			justify-content: space-between;
		}

		.right-box {
			color: #757575;
			display: flex;

			.select-button {
				margin-left: 20rpx;
				color: black;
			}
		}

		.button {
			background-color: #4169e1;
			color: white;
			font-size: 28rpx;
			margin: 0 20rpx;
			line-height: 80rpx;
			text-align: center;
			border-radius: 10rpx;
			margin-top: 60rpx;
		}
	}
</style>
